<template>
<div style="width: 100%">
  <a-card class="card" :bordered="false">
    <div class="table-page-search-wrapper">
      <a-form layout="vertical">
        <a-row :gutter="48">
          <a-col :sm="{span:24}" :lg="{span:16}" :xl="{span:16}">
            <a-form-item label="考生报名号范围">
              <a-input style="float:left;width:100px" placeholder="请输入..." v-model="queryParam.ksbmhStart"></a-input>
              <div style="float:left;padding:0 10px;" >至</div>
              <a-input style="float:left;width:100px" placeholder="请输入..."  v-model="queryParam.ksbmhEnd"></a-input>
            </a-form-item>
          </a-col>
          <a-col :sm="{span:12}" :lg="{span:12}" :xl="{span:6}">
            <a-form-item label="学年">
              <a-select :allowClear="true" showSearch optionFilterProp="children" v-model="queryParam.zsnj">
                <a-select-option v-for="i in TYPE0126" :key="i.id" :value="i.code">{{ i.name }}</a-select-option>
              </a-select>
            </a-form-item>
          </a-col>
          <a-col :sm="{span:24}" :lg="{span:8}" :xl="{span:8}" style="padding-top: 29px;">
            <a-button type="primary" @click="loadData">查询</a-button>
            <a-button type="primary" @click="handleBatchPrint">批量打印</a-button>
          </a-col>
        </a-row>
      </a-form>
    </div>
    </a-card>
    <a-card class="card" :bordered="false">
    <a-table
      ref="table"
      size="default"
      rowKey="key"
      :columns="columns"
      :loading="loading"
      :dataSource="data"
      :pagination="pagination"
			@change="handleTableChange"
    >
      <span slot="serial" slot-scope="text, record, index">
        {{ index + 1 }}
      </span>
    </a-table>
    </a-card>
</div>
</template>

<script>
// import moment from 'moment'
import { STable } from '~'
import { mapState } from 'vuex'

const selectArr = ['TYPE0126']

export default {
  components: {
    STable
  },
  data () {
    return {
      loading: false,
      data: [],
      // 查询参数
      queryParam: {
        ksbmhStart:'',
        ksbmhEnd:''
      },
      postParams: {

      },
      // 表头
      columns: [
        {
          title: '序号',
          scopedSlots: { customRender: 'serial' }
        },
        {
          title: '报名号',
          dataIndex: 'ksbmh'
        },
        {
          title: '姓名',
          dataIndex: 'ksxm'
        },
        {
          title: '报考导师',
          dataIndex: 'bkdsyxm'
        },
        {
          title: '报考院系',
          dataIndex: 'bkyxsmc'
        },
        {
          title: '报考专业',
          dataIndex: 'bkzymc'
        },
        {
          title: '证件号码',
          dataIndex: 'zjhm'
        },
        {
          title: '审核状态',
          dataIndex: 'qrzt'
        }
      ],
      selectMenu: {
        yx: [] // 院系
      },
      pagination: {
					current: 1
				}
    }
  },
  computed: {
    ...mapState({
      systemInfo: state => state.app.systemInfo,
      TYPE0126: state => state.app['TYPE0126'] // 年级
    })
  },
  created () {
     this.$api.base.getSchoolYear().then(res=>{
        this.$set(this.queryParam,'zsnj',res.data.doctoralAdmissionYear)
        // this.queryParam.zsnj=res.data.doctoralAdmissionYear
        this.loadData({
          pageNum:1,
          pageSize:10
        })
    })
  },
  methods: {
     // 加载数据
    loadData (parameter) {
      if(!parameter.pageNum){
         this.pagination.current = 1
         parameter.pageNum = 1
       }
      let params = Object.assign(this.queryParam, parameter)
      this.$api.doctorRecruit.batchPrinting(params).then(res=>{
        // console.log(res)
        if(res.data){
          const pagination = { ...this.pagination };
          this.data = res.data.rows;
          pagination.total = res.data.total;
          this.loading = false;
          this.pagination = pagination;
          this.data.forEach(item=>{
            if(item.qrzt==0){
              item.qrzt='待审核'
            }else{
              item.qrzt='已审核'
            }
          })
        }
      })
    },
    // 分页
			handleTableChange(pagination, filters, sorter) {
				console.log(pagination);
				const pager = { ...this.pagination
				};
				pager.current = pagination.current;
				this.pagination = pager;
				this.loadData({
					pageSize: 10,
					pageNum: pagination.current
				});
			},
    // 批量答应
    handleBatchPrint () {
      this.$export('admissions/bsksbmxx/exportPrint',this.queryParam)
    }
  }
}
</script>

<style lang="less" scoped>
.card{
  margin-bottom: 20px;
}
</style>
